set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_CROSS_COMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
set(CMAKE_OSX_SYSROOT $ENV{OSX_XCOMPILE_TOOLS}/target/SDK/MacOSX11.3.sdk)
set(TOOLCHAIN_PREFIX $ENV{OSX_XCOMPILE_TOOLS}/target/bin/$ENV{OSX_XCOMPILE_TARGET})

set(CMAKE_SYSROOT $ENV{OSX_XCOMPILE_ROOT}/osx-rootfs)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-clang)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-clang++-libc++)
set(CMAKE_C_COMPILER_AR ${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_CXX_COMPILER_AR ${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}-ld)
set(CMAKE_INSTALL_NAME_TOOL ${TOOLCHAIN_PREFIX}-install_name_tool)

set(CMAKE_FIND_ROOT_PATH $ENV{OSX_XCOMPILE_ROOT}/osx-rootfs/usr)
set(CMAKE_SYSTEM_PREFIX_PATH /)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@rpath")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(CMAKE_CXX_FLAGS "-Wl,-rpath,@loader_path")
